import { api } from '@/utils/request'
import type { 
  PostCategory, 
  PostCategoryPageParams,
  PostCategoryRequest,
  PageResult,
  ApiResponse
} from '@/types'

/**
 * 帖子分类管理API服务
 */
export class PostCategoryService {
  /**
   * 分页查询帖子分类列表
   */
  static async getPostCategoryPage(params: PostCategoryPageParams): Promise<PageResult<PostCategory>> {
    const response = await api.post<PageResult<PostCategory>>('/circle/api-admin/sPostCategory/page', params)
    return response.data
  }

  /**
   * 获取帖子分类详情
   */
  static async getPostCategoryDetail(id: number): Promise<PostCategory> {
    const response = await api.get<PostCategory>(`/circle/api-admin/sPostCategory/get/${id}`)
    return response.data
  }

  /**
   * 新增帖子分类
   */
  static async createPostCategory(categoryData: PostCategoryRequest): Promise<boolean> {
    const response = await api.post<boolean>('/circle/api-admin/sPostCategory/create', categoryData)
    return response.data
  }

  /**
   * 更新帖子分类
   */
  static async updatePostCategory(categoryData: PostCategoryRequest): Promise<boolean> {
    const response = await api.post<boolean>('/circle/api-admin/sPostCategory/update', categoryData)
    return response.data
  }

  /**
   * 删除帖子分类
   */
  static async deletePostCategory(id: number): Promise<boolean> {
    const response = await api.delete<boolean>(`/circle/api-admin/sPostCategory/delete/${id}`)
    return response.data
  }

}

// 默认导出单例实例
export const postCategoryService = PostCategoryService 